﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PlatypusPlanner.Components.BLL;
using PlatypusPlanner.Components.Database;
using PlatypusPlanner.Components.Enumerations;
using PlatypusPlanner.ViewControls;
using PlatypusPlanner.ViewControls.Utility;

namespace PlatypusPlanner.UserControls
{
    public partial class ClubRegistrationForm : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void submit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                ClubCreationStatus status = ClubCreationStatus.NotSet;

                pp_user creator = ((BasePage)Page).CurrentUser;

                new Clubs().InsertUpdate(null, creator, creator, -1, DateTime.Today, ClubBioTxt.Text, WebURLTxt.Text, AddressTxt.Text, CityTxt.Text, StateTxt.Text, ZipTxt.Text, clubNameTxt.Text, out status);

                switch (status)
                {
                    case ClubCreationStatus.Success:
                        break;
                    case ClubCreationStatus.GeneralError:
                        errorMessageLbl.Visible = true;
                        errorMessageLbl.Text = "Sorry for the inconvience, an error has occurred. Please contact tech support.";
                        break;
                    case ClubCreationStatus.DuplicateClubName:
                        errorMessageLbl.Visible = true;
                        errorMessageLbl.Text = "Sorry, this email already exists, please input a different email or use the forgoten password.";
                        break;
                }
                

            }

        }
    }
}